home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lantools / blueprnt / fileserv.mod < prev    next >
Text File  |  1989-09-27  |  5KB  |  171 lines

  1. ;************************************************************
  2. ;* Network Hub File Server Module            (FILESERV.MOD) *
  3. ;* by Craig Chaiken                                         *
  4. ;* August 25, 1989                                          *
  5. ;*                                                          *
  6. ;* Function :    Processes Hub Sector Read/Write Requests.  *
  7. ;* Requirements: None                                       *
  8. ;************************************************************
  9. ;
  10. ;*** Variables ***
  11. ;
  12. startsect       dw      ?
  13. function        db      ?
  14. drive           db      ?
  15. drive_table     db      maxsockets*32 dup (-1)  ;all drives need updating
  16. seclen_table    dw      26 dup (512)            ;sector length of drives A-Z
  17.  
  18. fileser proc    near            ;*** Read from or Write to Hub Sector ***
  19.         mov     al,packet_buffer
  20.         cmp     al,'R'
  21.         jnz     files1
  22.         jmp     reasec
  23. files1: cmp     al,'W'
  24.         jnz     files2
  25.         jmp     wrisec
  26. files2: cmp     al,'M'
  27.         jnz     files3
  28.         jmp     ckmedia
  29. files3: ret
  30. fileser endp
  31.  
  32. reasec  proc    near            ;*** Read from Sector on Hub's Drive
  33.         call    charout
  34.         mov     packet_buffer,'D'       ;descriptor for data packet
  35.         mov     al,packet_buffer[1]
  36.         mov     drive,al                ;get drive
  37.         mov     cl,packet_buffer[2]     ;get LSB absolute sector
  38.         mov     ch,packet_buffer[3]     ;get MSB absolute sector
  39.         mov     startsect,cx
  40.         or      cx,0
  41.         jnz     rloop1
  42.         mov     ah,36h
  43.         mov     dl,drive
  44.         inc     dl
  45.         int     21h
  46.         push    bx
  47.         xor     bh,bh
  48.         mov     bl,drive
  49.         add     bx,bx
  50.         mov     seclen_table[bx],cx
  51.         pop     bx
  52. rloop1: mov     function,0              ;function = read sector
  53.         call    sector_io
  54.         push    bx
  55.         push    cx
  56.         xor     bh,bh
  57.         mov     bl,drive
  58.         add     bx,bx
  59.         mov     cx,seclen_table[bx]
  60.         add     cx,4
  61.         mov     word ptr packet_length,cx
  62.         pop     cx
  63.         pop     bx
  64.         put_packet      socket_num,packet_length,offset packet_buffer
  65.         ret
  66. reasec  endp
  67.  
  68. wrisec  proc    near            ;*** Write to Sector on Hub's Drive ***
  69.         call    change_flag
  70. wrise0: call    charout
  71.         mov     packet_buffer,'D'
  72.         mov     al,packet_buffer[1]
  73.         mov     drive,al                ;get drive
  74.         mov     cl,packet_buffer[2]     ;get LSB absolute sector
  75.         mov     ch,packet_buffer[3]     ;get MSB absolute sector
  76.         mov     startsect,cx
  77. wrise1: mov     function,1
  78.         lea     bx,packet_buffer[4]
  79.         call    sector_io
  80.         get_packet      socket_num,packet_length,offset packet_buffer
  81.         mov     al,packet_buffer
  82.         cmp     al,'T'
  83.         jnz     wrise0
  84.         ret
  85. wrisec  endp
  86.  
  87. sector_io       proc    near    ;*** Process One Sector on Hub's Drive ***
  88.         pushall
  89.         mov     ax,cs
  90.         mov     es,ax
  91.         mov     ds,ax
  92.         mov     al,' '
  93.         call    charout
  94.         mov     al,drive
  95.         add     al,'A'
  96.         call    charout
  97.         mov     ax,startsect
  98.         call    decout
  99.         mov     al,13
  100.         call    charout
  101.         mov     al,drive
  102.         mov     cx,1            ;manipulate 1 sector
  103.         mov     dx,startsect    ;get starting sector
  104.         lea     bx,packet_buffer[4]
  105.         mov     ah,function
  106.         or      ah,ah
  107.         jz      rsect
  108.         int     26h
  109.         jnc     secto2
  110.         jmp     secto1
  111. rsect:  int     25h
  112.         jnc     secto2
  113. secto1: mov     packet_buffer,'E'
  114.         mov     word ptr packet_buffer[2],ax
  115. secto2: popf
  116.         popall
  117.         ret
  118. sector_io       endp
  119.  
  120. get_drive       proc    near    ;SI=offset of drive modification flag
  121.         push    ax
  122.         push    bx
  123.         push    cx
  124.         mov     cl,5
  125.         xor     bh,bh
  126.         shl     bx,cl
  127.         xor     ah,ah
  128.         add     bx,ax
  129.         lea     si,drive_table
  130.         add     si,bx
  131.         pop     cx
  132.         pop     bx
  133.         pop     ax
  134.         ret
  135. get_drive       endp
  136.  
  137. change_flag     proc    near    ;mark drive as modified for all sockets
  138.         push    ax
  139.         push    cx
  140.         push    si
  141.         mov     cx,maxsockets
  142.         lea     si,drive_table
  143.         xor     ah,ah
  144.         mov     al,drive
  145.         add     si,ax
  146. chang1: mov     byte ptr [si],-1        ;mark drive as modified
  147.         add     si,32                   ;next socket
  148.         loop    chang1
  149.         pop     si
  150.         pop     cx
  151.         pop     ax
  152.         ret
  153. change_flag     endp
  154.  
  155. ckmedia proc    near
  156.         call    charout
  157.         push    si
  158.         call    get_drive
  159.         mov     al,[si]
  160.         mov     byte ptr [si],1
  161.         pop     si
  162.         mov     packet_buffer[2],al
  163.         mov     word ptr packet_length,4
  164.         put_packet      socket_num,packet_length,offset packet_buffer
  165.         ret
  166. ckmedia endp
  167.  
  168. ;************************************************************
  169. ;* End of Network File Server Module                        *
  170. ;************************************************************
  171.